<?php
/**
 * Created by PhpStorm.
 * User: wumengmeng <wu_mengmeng@foxmail.com>
 * Date: 2019/4/26 0026
 * Time: 16:54
 */

namespace Modules\Shop\Http\Middleware;

use Closure;
use HiCommon\Model\EntrustPermissions;
use HiCommon\Service\MongoLogService;
use Illuminate\Http\Request;
use Modules\Admin\Service\LogService;

class ShopActionLog
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        if($request->method() != 'GET'){
            $arrData = [
              'url'=>$request->url(),
              'route'=>$request->route()->getName(),
              'method'=>$request->method(),
              'data'=>$request->input(),
              'actionmethod'=>$request->route()->getActionMethod(),
              'actinname'=>$request->route()->getActionName(),
              'ip'=>$request->ip(),
              'user_id'=>shop_user_id(),
              'username'=>shop_user()->username
            ];
            MongoLogService::shop_user_action($arrData);//记录操作日志
        }
        return $next($request);
    }
}